﻿using BCDto.UploadHandleComponent;
using System;
using System.Collections.Generic;
using System.Text;
using WeChatSDK.Common.Enums.Material;
using WeChatSDK.WeChatDto.Material;

namespace BCService.WeChatComponent.WeChatMaterialService.WeChatMaterialService
{
    /// <summary>
    /// 微信素材服务
    /// </summary>
    public interface IWeChatMaterialService
    {
        /// <summary>
        /// 上传临时文件到微信
        /// </summary>
        void UploadTemporaryFileToWeChat();
        /// <summary>
        /// 上传素材
        /// </summary>
        /// <param name="uploadFileDto">上传文件信息</param>
        /// <param name="isPermanent">是否永久素材</param>
        /// <returns>{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789}</returns>
        string UploadWeChatMedial(UploadFileDto uploadFileDto, bool isPermanent);
        /// <summary>
        /// 微信素材上传检查
        /// </summary>
        /// <param name="uploadFileDto">上传文件信息</param>
        void WeChatMaterialCheckData(UploadFileDto uploadFileDto);

        /// <summary>
        /// 获取微信素材总数
        /// </summary>
        /// <returns>{"voice_count":COUNT,"video_count":COUNT,"image_count":COUNT,"news_count":COUNT}</returns>
        string GetWeChatMaterialCount();
        /// <summary>
        /// 获取微信素材列表
        /// </summary>
        /// <param name="materialType">素材类型</param>
        /// <param name="offset">从全部素材的该偏移位置开始返回，0表示从第一个素材 返回</param>
        /// <param name="count">返回素材的数量，取值在1到20之间</param>
        /// <returns>
        /// 图文素材：
        /// {
        ///   "total_count": TOTAL_COUNT,
        ///   "item_count": ITEM_COUNT,
        ///   "item": [{
        ///       "media_id": MEDIA_ID,
        ///       "content": {
        ///           "news_item": [{
        ///               "title": TITLE,
        ///               "thumb_media_id": THUMB_MEDIA_ID,
        ///               "show_cover_pic": SHOW_COVER_PIC(0 / 1),
        ///               "author": AUTHOR,
        ///               "digest": DIGEST,
        ///               "content": CONTENT,
        ///               "url": URL,
        ///               "content_source_url": CONTETN_SOURCE_URL
        ///           },
        ///           //多图文消息会在此处有多篇文章
        ///           ]
        ///        },
        ///        "update_time": UPDATE_TIME
        ///    },
        ///    //可能有多个图文消息item结构
        ///  ]
        ///}
        /// 其他素材：（图片、语音、视频）
        /// {
        ///   "total_count": TOTAL_COUNT,
        ///   "item_count": ITEM_COUNT,
        ///   "item": [{
        ///       "media_id": MEDIA_ID,
        ///       "name": NAME,
        ///       "update_time": UPDATE_TIME,
        ///       "url":URL
        ///   },
        ///   //可能会有多个素材
        ///   ]
        ///}
        /// </returns>
        string GetWeChatMaterialList(MaterialType materialType, int offset, int count);
        /// <summary>
        /// 获取素材
        /// </summary>
        /// <param name="mediaId">素材Id</param>
        /// <param name="isPermanent">是否永久素材</param>
        /// <param name="isHD">是否高清</param>
        /// <returns>
        /// 获取临时素材：
        ///     {
        ///         "video_url":DOWN_URL
        ///     }
        /// 获取临时高清语音素材：
        ///     高清语音素材获取后返回的是speex音频格式的字节数据，Convert.FromBase64String(value);
        ///     如果speex音频格式不符合业务需求，开发者可在获取后，再自行于本地对该语音素材进行转码。
        /// 获取永久素材：
        ///     永久其他素材
        ///     {
        ///         "media_id":MEDIA_ID
        ///     }
        ///     永久图文素材
        ///     {
        ///         "news_item":
        ///         [
        ///             {
        ///             "title":TITLE,
        ///             "thumb_media_id"::THUMB_MEDIA_ID,
        ///             "show_cover_pic":SHOW_COVER_PIC(0 / 1),
        ///             "author":AUTHOR,
        ///             "digest":DIGEST,
        ///             "content":CONTENT,
        ///             "url":URL,
        ///             "content_source_url":CONTENT_SOURCE_URL
        ///             },
        ///             //多图文消息有多篇文章
        ///         ]
        ///     }
        ///     永久视频素材
        ///     {
        ///         "title":TITLE,
        ///         "description":DESCRIPTION,
        ///         "down_url":DOWN_URL,
        ///     }
        /// </returns>
        byte[] GetWeChatMaterialInfo(string mediaId, bool isPermanent, bool isHD);
        /// <summary>
        /// 获取素材
        /// </summary>
        /// <param name="mediaId">素材Id</param>
        /// <param name="isPermanent">是否永久素材</param>
        /// <returns>
        /// 获取临时素材：
        ///     {
        ///         "video_url":DOWN_URL
        ///     }
        /// 获取永久素材：
        ///     永久其他素材
        ///     {
        ///         "media_id":MEDIA_ID
        ///     }
        ///     永久图文素材
        ///     {
        ///         "news_item":
        ///         [
        ///             {
        ///             "title":TITLE,
        ///             "thumb_media_id"::THUMB_MEDIA_ID,
        ///             "show_cover_pic":SHOW_COVER_PIC(0 / 1),
        ///             "author":AUTHOR,
        ///             "digest":DIGEST,
        ///             "content":CONTENT,
        ///             "url":URL,
        ///             "content_source_url":CONTENT_SOURCE_URL
        ///             },
        ///             //多图文消息有多篇文章
        ///         ]
        ///     }
        ///     永久视频素材
        ///     {
        ///         "title":TITLE,
        ///         "description":DESCRIPTION,
        ///         "down_url":DOWN_URL,
        ///     }
        /// </returns>
        byte[] GetWeChatMaterialInfo(string mediaId, bool isPermanent);
    }
}
